package com.flca.frw.zk.validate;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zul.Constraint;

/**
 * This class validates if an combobo item is selected
 * @author rbakkerus
 *
 */
public class ValidateCombobox implements Constraint {

	private static final String ERRMSG = "Ten minste een telefoonnummer moet gevuld zijn";
	
	public void validate(Component aComp, Object aValue)
			throws WrongValueException 
	{
		if (aValue != null && aValue instanceof String) {
			String s = (String) aValue;
			if (s.trim().length() == 0 || s.indexOf("...") > 0) {
				throw new WrongValueException(aComp, ERRMSG);
			}
		} else {
			throw new WrongValueException(aComp, ERRMSG);
		}
	}

}
